package o;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.widget.Switch;
import com.huawei.skinner.annotation.SkinAdapter;
import o.fkp.e;

public class fto {
    @SkinAdapter("thumb")
    public static void ˎ(Switch switchR, Drawable drawable) {
        if (VERSION.SDK_INT >= 23) {
            switchR.setThumbDrawable(drawable);
            switchR.setThumbTintList(switchR.getThumbTintList());
        } else {
            Object tag = switchR.getTag(e.ˎ);
            if (tag != null && (tag instanceof ColorStateList)) {
                ColorStateList colorStateList = (ColorStateList) tag;
                drawable = gg.ʻ(drawable).mutate();
                gg.ॱ(drawable, colorStateList);
                gg.ˋ(drawable, Mode.SRC_IN);
            }
            switchR.setThumbDrawable(drawable);
        }
        if (switchR.getClass().getName().equals("com.huawei.support.widget.HwSwitch")) {
            fmt.ˏ(switchR.getClass(), switchR, "mThumbDrawable", drawable);
        }
    }

    @SkinAdapter("thumbTint")
    public static void ˎ(Switch switchR, ColorStateList colorStateList) {
        if (VERSION.SDK_INT >= 23) {
            switchR.setThumbTintList(colorStateList);
            return;
        }
        Drawable thumbDrawable = switchR.getThumbDrawable();
        if (thumbDrawable != null) {
            Drawable mutate = gg.ʻ(thumbDrawable).mutate();
            gg.ॱ(mutate, colorStateList);
            gg.ˋ(mutate, Mode.SRC_IN);
            if (thumbDrawable != mutate) {
                switchR.setThumbDrawable(mutate);
            }
        }
        switchR.setTag(e.ˎ, colorStateList);
    }

    @SkinAdapter("track")
    public static void ˏ(Switch switchR, Drawable drawable) {
        if (VERSION.SDK_INT >= 23) {
            switchR.setTrackDrawable(drawable);
            switchR.setTrackTintList(switchR.getTrackTintList());
        } else {
            Object tag = switchR.getTag(e.ॱ);
            if (tag != null && (tag instanceof ColorStateList)) {
                ColorStateList colorStateList = (ColorStateList) tag;
                drawable = gg.ʻ(drawable).mutate();
                gg.ॱ(drawable, colorStateList);
                gg.ˋ(drawable, Mode.SRC_IN);
            }
            switchR.setTrackDrawable(drawable);
        }
        if (switchR.getClass().getName().equals("com.huawei.support.widget.HwSwitch")) {
            fmt.ˏ(switchR.getClass(), switchR, "mTrackDrawable", drawable);
        }
    }

    @SkinAdapter("trackTint")
    public static void ˊ(Switch switchR, ColorStateList colorStateList) {
        if (VERSION.SDK_INT >= 23) {
            switchR.setTrackTintList(colorStateList);
            return;
        }
        Drawable trackDrawable = switchR.getTrackDrawable();
        if (trackDrawable != null) {
            Drawable mutate = gg.ʻ(trackDrawable).mutate();
            gg.ॱ(mutate, colorStateList);
            gg.ˋ(mutate, Mode.SRC_IN);
            if (trackDrawable != mutate) {
                switchR.setTrackDrawable(mutate);
            }
        }
        switchR.setTag(e.ॱ, colorStateList);
    }
}
